package com.pinkpig.excel.ext.style;

import com.alibaba.excel.metadata.Head;
import com.alibaba.excel.write.style.column.AbstractHeadColumnWidthStyleStrategy;

import java.util.Map;

/**
 * @Author vincenfeng
 * @Date 2020/5/22 16:27
 */
public class MultiColumnWidthStyleStrategy extends AbstractHeadColumnWidthStyleStrategy {

    private Map<Integer, Integer> columnsWidth;

    /**
     *
     * @param columnWidth
     */
    public MultiColumnWidthStyleStrategy(Map<Integer, Integer> columnsWidth) {
        this.columnsWidth = columnsWidth;
    }

    @Override
    protected Integer columnWidth(Head head, Integer columnIndex) {
        if(columnsWidth.containsKey(columnIndex)){
            return columnsWidth.get(columnIndex);
        }
        return null;
    }
}
